package com.study.pattern.observer.usingjdk;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

public class CheerLeaderGroup extends Observable {
	
	List<LadyObserver>ladyList = new ArrayList<LadyObserver>();

	public void startChant(){
		for(int i=0;i<3;i++){
			startThread();
		}
	}

	private void startThread() {
		LadyObserver lady = LadyObserver.newInstance();
		this.addObserver(lady);
		Thread ladyThread = new Thread(lady);
		ladyThread.start();
		ladyList.add(lady);
	}
	
	public void setChanged(){
		super.setChanged();
	}

	public void terminateLady(){
		for(LadyObserver lady : ladyList){
			lady.destroyLady();
		}
	}
}
